package com.qf.cx.simplenms.persist.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "Subscriber", uniqueConstraints = { @UniqueConstraint(columnNames = { "url" }) })
public class SubscriberEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;

	@Column(nullable = false)
	private String url;

	@Column
	private String statusUrl;

	@ManyToMany(targetEntity = TopicEntity.class, fetch = FetchType.EAGER)
	@JoinTable(name = "Topic_Subscriber", joinColumns = @JoinColumn(name = "subscriberId"), inverseJoinColumns = @JoinColumn(name = "topicName"))
	private List<TopicEntity> topicEntities;

	public List<TopicEntity> getTopicEntities() {
		return topicEntities;
	}

	public void setTopicEntities(List<TopicEntity> topicEntities) {
		this.topicEntities = topicEntities;
	}

	public String getStatusUrl() {
		return statusUrl;
	}

	public void setStatusUrl(String statusUrl) {
		this.statusUrl = statusUrl;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

}
